package test;

import java.util.List;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;

import projectsupporter.common.formbase.progrees.LongRunningOperation;
import projectsupporter.common.formbase.progrees.ProgressBarDialog;

public class ProgressBarExample3 {
	
	protected List<String> list;
	
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new GridLayout());
		shell.open();
		
		
		
		//添加线程，在线程中处理长时间的任务，并最终反映在平滑进度条上
		new LongRunningOperation(shell)
		{
			
			public void run() {
				
				display.asyncExec(new Runnable() {
					public void run() {
						progressBar.open();
						progressBar.setMax(30);
						progressBar.setMin(0);
						
					}
				});
				
				for (int i = 0; i < 300; i++) {
				try {
					Thread.sleep(100);
					} catch (InterruptedException e) {

					}
					
					move(i,""+i);
				}
			}
		}.start();
		
		
		while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
		display.sleep();
		}
		}
		}
		}
